package conf
import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

// RedisSection map toml [redis]
type RedisSection struct {
	Address  string `mapstructure:"address"`  // data source name.
	Password string `mapstructure:"password"` // pwd
	DB       int    `mapstructure:"db"`       // pool
}

// ReadRedis get pg section from config
func ReadRedis (v *viper.Viper, slog *zap.SugaredLogger) (redisConf RedisSection) {
	err := v.Unmarshal(&redisConf)
	if err != nil {
		slog.Panicf("unable to decode into redis section, %v", err)
	}
	slog.Debug(redisConf)
	return
}